﻿using Demo.WebApi.Models.Products;
using Demo.WebApi.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Demo.WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductController : ControllerBase
    {
        public IProductService productService;
        public ProductController(IProductService productService)
        {
            this.productService = productService;
        }

        [HttpPost]
        public string AddProduct(Product product)
        {
            productService.AddProduct(product);
            return "添加成功";
        }
        [HttpPost]
        public List<Product> SelectProduct(Product product)
        {
            return productService.SelectdProduct(product);
        }
    }
}
